package com.ruiyin.controller;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.apache.log4j.Logger;

import com.jfinal.core.Controller;

public class BaseController extends Controller{

	private static Logger log = Logger.getLogger(BaseController.class);

	public void index(){
		renderJsp("/index.jsp");
	}
	
	public Map<String,Object> getPageData(){
		Map<String, String[]> properties = getParaMap();
		Map<String,Object> returnMap = new HashMap<String,Object>(); 
		Iterator entries = properties.entrySet().iterator(); 
		Map.Entry entry; 
		String name = "";  
		String value = "";  
		while (entries.hasNext()) {
			entry = (Map.Entry) entries.next(); 
			name = (String) entry.getKey(); 
			Object valueObj = entry.getValue(); 
			if(null == valueObj){ 
				value = ""; 
			}else if(valueObj instanceof String[]){ 
				String[] values = (String[])valueObj;
				for(int i=0;i<values.length;i++){ 
					 value = values[i] + ",";
				}
				value = value.substring(0, value.length()-1); 
			}else{
				value = valueObj.toString(); 
			}
			returnMap.put(name, value); 
		}
		return returnMap;
	}
}
